package com.woniu.park.util;

import lombok.Data;

import java.util.List;

@Data
public class PageResult<T>  extends  Result{
    private long totalCount;

    private long totalPage;

    private long pageIndex;

    private long pageSize;

    private List<T> content;

    public PageResult(boolean success, String code, String message, long totalCount, long pageIdx, long pageSize, List<T> content) {
        super(success, code, message, null);
        this.totalCount = totalCount;
        this.pageIndex = pageIdx;
        this.pageSize = pageSize;
        this.content = content;
        this.totalPage = totalCount%pageSize==0?(totalCount/pageSize):(totalCount/pageSize)+1;
    }

    public static PageResult success(long totalCount, long pageIdx, long pageSize, List content){
        return new PageResult(true,"SUCCESS","查询成功",totalCount,pageIdx,pageSize,content);
    }

}
